package com.wct.springcloud.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RetryRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author WEI (Email:changtan20000@163.com)
 * @description
 * @date: 2019/12/11 21:00
 */
@Configuration
public class ConfigBean {

    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

    @Bean
    public IRule myIRule(){
        /**
         * 默认使用轮询 RoundRobinRule
         * 随机 RandomRule
         * 轮询 + RetryRule
         */
        return new RetryRule();
    }
}
